﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OracleClient;

namespace XWG.JWBST.JWBSTDAL
{
    public class TbBstDownLoad
    {
        public static int GetLastDownLoad()
        {
            string sql = "select * from TB_BST_DOWNLOAD";
            if (string.IsNullOrEmpty(OrclHelper.ExecuteScalar(sql).ToString()))
            {
                string insertsql = "insert into TB_BST_DOWNLOAD(DOWNLOADTRAFFICSTATISTICS)values(0)";
                if (OrclHelper.ExecuteOracle(insertsql) != 0)
                {
                    return 0;
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                return Convert.ToInt32(OrclHelper.ExecuteScalar(sql));
            }
        }

        public static void UpdateDownLoad(int num)
        {
            string sql = "update TB_BST_DOWNLOAD set DOWNLOADTRAFFICSTATISTICS = :num";
            OracleParameter[] sp = { 
                                   new OracleParameter(":num",num),
                                   };
            OrclHelper.ExecuteOracle(sql, sp);
        }
    }
}
